package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.ExpressionDescribe;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextreplacer.ParseContextReplacer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;
import org.zhadoop.streaming.util.StreamingDataType;

/**
 * cast 表达式解析内容
 * 
 * @author zwd
 *
 */
public class CastExpressionContext extends BaseExpressionParseContext {

	private BaseExpressionParseContext expression;

	private StreamingDataType datatype;

	public BaseExpressionParseContext getExpression() {
		return expression;
	}

	public void setExpression(BaseExpressionParseContext expression) {
		this.expression = expression;
	}

	public StreamingDataType getDatatype() {
		return datatype;
	}

	public void setDatatype(StreamingDataType datatype) {
		this.datatype = datatype;
	}

	@Override
	public void walkChildAndReplace(ParseContextReplacer replacer) {
		// TODO Auto-generated method stub

	}

	@Override
	protected ExpressionDescribe createExpressionDesc() throws SemanticAnalyzerException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(" cast ");
		sb.append(" ( ");
		sb.append(expression.toString());
		sb.append(" AS ");
		sb.append(datatype.getDesc());
		sb.append(" ) ");
		return sb.toString();
	}

	@Override
	protected void walkChild(ParseContextWalker walker) {
		// TODO Auto-generated method stub

	}

}
